package com.swjd.servletComponent;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
//注册方式
//@Component
////整合Filter 拦截器
//注解扫描方式
@WebFilter(value = {"/toLoginPage"})
public class MyFilter implements Filter {
    //初始化
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }
    //业务逻辑
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("myFilter执行了》》》》》》》》");
        filterChain.doFilter(servletRequest,servletResponse);
    }
    //销毁
    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
